"======================================================================
"
" init-plugin-ui.vim - 编辑样式插件
"
"======================================================================


"----------------------------------------------------------------------
" 插件 --- xkbswitch
" 输入法切换
"----------------------------------------------------------------------
" 启动输入法切换
let g:XkbSwitchEnabled = 1
" （win）设置切换动态链接库路径
" let g:XkbSwitchLib = '/usr/local/lib/libxkbswitch.so'


"----------------------------------------------------------------------
" 插件 --- easy-align
" 使用指定符号自动对齐
"----------------------------------------------------------------------
nmap <Leader>a <plug>(EasyAlign)
xmap <Leader>a <plug>(EasyAlign)


"----------------------------------------------------------------------
" 插件 --- leaderf
"----------------------------------------------------------------------
" leaderf
let g:Lf_WindowPosition       = 'top'
let g:Lf_CacheDirectory       = $XDG_DATA_HOME
let g:Lf_WindowHeight         = 0.5
let g:Lf_StlColorscheme       = 'one'
let g:Lf_RootMarkers = ['.git', '.hg', '.svn', '.vscode', '.idea']
let g:Lf_WildIgnore           = {
    \ 'dir': ['.svn','.git','.hg', '.idea', '.vscode'],
    \ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[co]', '*.zip', '*.gz']
    \ }
let g:Lf_StlSeparator         = { 'left': '', 'right': '' }
let g:Lf_PreviewCode          = 1
let g:Lf_WorkingDirectoryMode = 'c'
let g:Lf_RgConfig             = [
    \ "--max-columns=150",
    \ "--glob=!git/*",
    \ "--hidden"
    \ ]
let g:Lf_NoChdir              = 1
let g:Lf_PopupHeight          = 0.5
let g:Lf_PopupPreviewPosition = 'bottom'
let g:Lf_PreviewHorizontalPosition = 'right'
let g:Lf_PopupColorscheme = 'one'

" leaderf rg
let g:Lf_RgConfig = [
    \ "--max-columns=150",
    \ "--glob=!git/*",
    \ "--hidden"
    \ ]
" 全局搜索输入的单词
nmap <leader>rg :<C-U><C-R>=printf("Leaderf! rg --nowrap -F ")<cr>

" 全局搜索光标处的单词
nmap <leader>rw :<C-U><C-R>=printf("Leaderf! rg --nowrap -F %s ", expand("<cword>"))<cr>

" 在当前buffer里搜索光标处的单词
nmap <leader>rb :<C-U><C-R>=printf("Leaderf! rg --nowrap -F --current-buffer %s ", expand("<cword>"))<cr>

" 搜索选中的文本
xmap <leader>rg :<C-U><C-R>=printf("Leaderf! rg --nowrap -F %s ", leaderf#Rg#visual())<cr>

" 重新执行上一次搜索
nmap <leader>ro :<C-U>Leaderf! rg --recall<cr>

" leaderf gtags
let g:Lf_GtagsAutoGenerate = 0
" 原生语言 C C++ JAVA PHP使用内置解析器
let g:Lf_Gtagslabel = 'native-pygments'
" 更新tags
nmap <leader>gu :<C-U><C-R>=printf("Leaderf! gtags --update ")<cr><cr>
" 查询定义或引用
nmap <leader>gt :<C-U><C-R>=printf("Leaderf! gtags --by-context --auto-jump --path-style through")<cr><cr>
" 查询定义
"nmap <leader>gd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump --path-style through", expand("<cword>"))<cr><cr>
nmap <leader>gd <Plug>LeaderfGtagsDefinition

" 查询引用
nmap <leader>gr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump --path-style through", expand("<cword>"))<cr><cr>
" 重新执行上一次搜索
nmap <leader>go :<C-U><C-R>=printf("Leaderf! gtags --recall")<cr><cr>


"----------------------------------------------------------------------
" 插件 --- fugitive/gv
" git工具库
"----------------------------------------------------------------------
" 打开Git面板
nmap <Leader>vv :Git<CR>
" 显示提交记录树
nmap <Leader>vl :GV<CR>
" Git fetch
nmap <Leader>vf :Gfetch<CR>
" Git pull
nmap <Leader>vpl :Gpull<CR>
" Git commit
nmap <Leader>vc :Gcommit<CR>
" Git push
nmap <Leader>vpu :Gpush<CR>


"----------------------------------------------------------------------
" 插件 --- easymotion 
"----------------------------------------------------------------------
" 单字符跳转
map  sf <Plug>(easymotion-bd-f)
" 双字符跳转
nmap ss <Plug>(easymotion-overwin-f2)
" 行跳转
map  sl <Plug>(easymotion-bd-jk)
nmap sl <Plug>(easymotion-overwin-line)
" 单词跳转
map  sw <Plug>(easymotion-bd-w)
nmap sw <Plug>(easymotion-overwin-w)

